<!DOCTYPE html>
<html>
<head>
<title>ajaxDemo1.html</title>
<meta charset="UTF-8">
<meta name="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery.js"></script>
</head>

<body>
	<div id="showDiv"></div>
	<div>
		<input type="text" name="msg" id="msg"> <input type="button"
			id="mybut" name="mybut" value="提交">
	</div>

	<script type="text/javascript">
  			// 页面加载完成，点击按钮发送Ajax请求
  			$(function(){
  				$("#mybut").on("click",function(){
  					
  					$.ajax({
  						url:"echo",
  						method: "post",
  						data:{"msg": $("#msg").val(), info: "你好啊"},
  						dataType: "json",
  						success: function(data){
  							$("#showDiv").text(data.msg+","+data.info);
  						},
  						error:function(data){
  							alert("对不起，出错了!");
  						}
  					});
  					
  				});
  			
  			
  			});
  		
  		</script>

</body>
</html>
